/*
 * Cnanowire - computes current-voltage characteristic of bare cylindrical nanowire
 * Copyright (C) 2010  Oka Kurniawan
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
*/

#ifndef INCLUDED_NFILE
#define INCLUDED_NFILE

#ifndef INCLUDED_IOSTREAM
#define INCLUDED_IOSTREAM
#include <iostream>
#endif

#ifndef INCLUDED_FSTREAM
#define INCLUDED_FSTREAM
#include <fstream>
#endif

#ifndef INCLUDED_ITBASE
#define INCLUDED_ITBASE
#include <itpp/itbase.h>
#endif

#ifndef INCLUDED_STRING
#define INCLUDED_STRING
#include <string>
#endif

#ifndef INCLUDED_GCONST
#include "globalconst.h"
#endif

//! Class NFile.
/*! This class is used to write data into text files.
 */
class NFile
{
	itpp::vec d_xData; //!< vector of x data.
	itpp::vec d_yData; //!< vector of y data.
	std::string d_xLabel; //!< label for x data.
	std::string d_yLabel; //!< label for y data.
	std::string d_filename; //!< file name to be written to.
public:
	//! Constructor without any argument.
	/*! This will save the data by default to output.dat.
	 */
	NFile();

	//! Constructor.
	/*! Saves to fname as the name file.
	 */
	NFile(const std::string fname);

	virtual ~NFile();

	//! Add a vector of data to be saved.
	/*! - label: is the label of the data, by default is "X" and "Y"
	 * - data: is the vector to be saved
	 * - col: to specify which data
	 * 	-# 0: x data
	 * 	-# 1: y data
	 */
	void addData(std::string label, itpp::vec data, unsigned int col);

	//! Set the filename to be written.
	void setFileName(std::string  fname);

	//! Save to file with fname as its filename.
	void saveToFile(std::string fname);

	//! Save to file using the specified filename.
	void saveToFile(void);
};

#endif /*NFILE_H_*/
